package com.usian.controller;

import com.usian.pojo.TbUser;
import com.usian.service.SSOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class SSOServiceController {

    @Autowired
    SSOService ssoService;

    /**
     * 更新用户过期时间
     *
     * @param token
     * @return
     */
    @RequestMapping("getUserByToken/{token}")
    public boolean getUserByToken(@PathVariable String token){
        return ssoService.getUserByToken(token);
    }

    /**
     * 用户退出接口
     *
     * @param token
     * @return
     */
    @RequestMapping("logOut")
    public boolean logOut(@RequestParam String token){
        return ssoService.logOut(token);
    }

    /**
     * 用户登录接口
     *
     * @param username
     * @param password
     * @return
     */
    @RequestMapping("userLogin")
    public Map userLogin(@RequestParam String username, @RequestParam String password){
        return ssoService.userLogin(username,password);
    }

    /**
     * 12.注册验证接口
     *
     * @param checkValue
     * @param checkFlag
     * @return
     */
    @RequestMapping("checkUserInfo/{checkValue}/{checkFlag}")
    public boolean checkUserInfo(@PathVariable String checkValue, @PathVariable Integer checkFlag){
        return ssoService.checkUserInfo(checkValue,checkFlag);
    }

    /**
     * 用户注册接口
     *
     * @param tbUser
     * @return
     */
    @RequestMapping("userRegister")
    public Map userRegister(@RequestBody TbUser tbUser){
        return ssoService.userRegister(tbUser);
    }

}
